package com.zmn.oms.dubbo.controller;

import com.zmn.common.dto2.ResponseDTO;
import com.zmn.oms.common.dio.orderworkingrecord.OrderWorkingRecordDIO;
import com.zmn.oms.common.dio.quotation3.MaintainFaultOptionQuery;
import com.zmn.oms.common.dio.wallquotation.WallOrderAmountDIO;
import com.zmn.oms.common.dio.wallquotation.WallQuotationDIO;
import com.zmn.oms.common.dio.wallquotation.WallQuotationDetailDIO;
import com.zmn.oms.common.exception.OmsBaseException;
import com.zmn.oms.dubbo.interfaces.quotation.Quotation3OrderWorkListRemoteService;
import com.zmn.oms.dubbo.interfaces.wallquotation.WallQuotationListRemoteService;
import com.zmn.oms.dubbo.interfaces.wallquotation.WallQuotationModifyRemoteService;
import com.zmn.oms.dubbo.interfaces.zmn.orderworkingrecord.OrderWorkingRecordModifyRemoteService;
import com.zmn.oms.dubbo.utils.DubboConsts;
import com.zmn.oms.model.entity.wechatwork.OmsOrderWechatWorkLog;
import com.zmn.oms.services.interfaces.wechatwork.OmsOrderWechatWorkLogService;
import com.zmn.oms.zmn.business.interfaces.wallquotation.WallQuotationBService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;

/**
 * 测试墙面报价dubbo接口
 *
 * @author chengguang
 * @date 2022/06/02
 */
@RestController
@RequestMapping("/wall")
public class WallQuotationController {


    @DubboReference(version = DubboConsts.INTERFACE_VERSION, check = false)
    private WallQuotationListRemoteService wallQuotationListRemoteService;

    @DubboReference(version = DubboConsts.INTERFACE_VERSION, check = false)
    private WallQuotationModifyRemoteService wallQuotationModifyRemoteService;

    @DubboReference(version = DubboConsts.INTERFACE_VERSION, check = false)
    private OrderWorkingRecordModifyRemoteService orderWorkingRecordModifyRemoteService;

    @DubboReference(version = DubboConsts.INTERFACE_VERSION, check = false)
    private Quotation3OrderWorkListRemoteService quotation3OrderWorkListRemoteService;

    @Resource
    private WallQuotationBService wallQuotationBService;

    @Autowired
    private OmsOrderWechatWorkLogService omsOrderWechatWorkLogService;

    @GetMapping("/getWallQuotationServItemByOrderIdAndWorkId")
    public ResponseDTO getWallQuotationServItemByOrderIdAndWorkId(Long orderId, Long workId) {
        return wallQuotationListRemoteService.getWallQuotationServItemByOrderIdAndWorkId(orderId, workId);
    }

    @GetMapping("/getWallQuotationDetailByOrderIdAndWorkId")
    public ResponseDTO getWallQuotationDetailByOrderIdAndWorkId(Long orderId, Long workId) {
        return wallQuotationListRemoteService.getWallQuotationDetailByOrderIdAndWorkId(orderId, workId);
    }

    @PostMapping("/getWallOrderAmount")
    public ResponseDTO getWallOrderAmount(@RequestBody WallOrderAmountDIO wallOrderAmountDIO) {
        return wallQuotationListRemoteService.getWallOrderAmount(wallOrderAmountDIO);
    }

    @GetMapping("/isWallQuotation")
    public ResponseDTO isWallQuotation(Long orderId, Long workId) {
        return wallQuotationListRemoteService.isWallQuotation(orderId, workId);
    }

    /***********************************************************************************************/

    @PostMapping("/confirmWallQuotation")
    public ResponseDTO confirmWallQuotation(@RequestBody WallQuotationDIO wallQuotationDIO) {
        return wallQuotationModifyRemoteService.confirmWallQuotation(wallQuotationDIO);
    }

    @PostMapping("/addWallQuotationDetail")
    public ResponseDTO addWallQuotationDetail(@RequestBody WallQuotationDetailDIO wallQuotationDetailDIO) throws OmsBaseException {
        return wallQuotationModifyRemoteService.addWallQuotationDetail(wallQuotationDetailDIO);
    }

    @PostMapping("/addOrderWorkingRecord")
    public ResponseDTO addOrderWorkingRecord(@RequestBody OrderWorkingRecordDIO orderWorkingRecordDIO){
        return orderWorkingRecordModifyRemoteService.addOrderWorkingRecord(orderWorkingRecordDIO);
    }

    @PostMapping("/listMaintainOptionByMfoQuery")
    public ResponseDTO listMaintainOptionByMfoQuery(@RequestBody MaintainFaultOptionQuery maintainFaultOptionQuery){
        return quotation3OrderWorkListRemoteService.listMaintainOptionByMfoQuery(maintainFaultOptionQuery);
    }

    @GetMapping("/ccc")
    public ResponseDTO listMaintainOptionByMfoQuery(){
        OmsOrderWechatWorkLog omsOrderWechatWorkLog=new OmsOrderWechatWorkLog();
        omsOrderWechatWorkLog.setOrderId(355757495794360320L);
        omsOrderWechatWorkLog.setWorkId(355757495794360320L);
        omsOrderWechatWorkLog.setAddTime(new Date());
        omsOrderWechatWorkLog.setNickName("");
        omsOrderWechatWorkLog.setOperatorType(1L);
        omsOrderWechatWorkLog.setOperatorType(1L);
        omsOrderWechatWorkLogService.insert(omsOrderWechatWorkLog);
        return ResponseDTO.success();
    }
}
